#include "rs232.h"
#include "aduc812.h"
#include "repl.h"
#include "interrupt.h"

void repl() {
	char tmp[100];
	init_rs232();
	println_rs232("A long time ago in a galaxy far, far away...\n");
	while(1) {
			println_rs232("sdk$ " + 0);
			scanln_rs232(tmp);
			println_rs232(eval(tmp));
	}
}

char * eval(char * exp) {
	if (equals(exp, "start" + 0)) init_main_int();
	if (equals(exp, "stop" + 0)) ET0 = 0;
	return "" + 0;
}

char equals(char * s1, char * s2) {
	char ch1, ch2;
	while (1) {
		ch1 = *s1++; ch2 = *s2++;
		if ((ch1 == '\n' || ch1 == 0) && (ch2 == '\n' || ch2 == 0)) return 1;
		if (ch1 != ch2) return 0;
	}
}
